function getPath(){
	var u = window.location;/*      http://localhost:8888/web/meal/restaurant/list    */
	var p = window.location.pathname;/*    /web/meal/restaurant/list                 */
	var ps = p.split("/");
	var pth = "";
	for(var i = 0; i < ps.length; i++){
		if(ps[i]!=null && ps[i]!=''){
			pth = ps[i];
			break;
		}
	}
	return window.location.protocol /* http:  */
		+ "//" 
		+ window.location.host /*  localhost:8888   */
		+ "/"
		+ pth;  /*  web  */
}

$(document).ajaxError(function(event,request, settings){
	var content = '不好意思,出错啦。';
	var resultText = request.responseText;
	if(resultText && resultText.indexOf('OUTOF-LOGIN')>-1){
		if(typeof(window.top.showAjaxLogin)=='function'){
			window.top.showAjaxLogin();
		}else{
			alert("你需要重新登录才可以进行操作");
		}
	}else{
		function showErrorMsg(){
			var errorLog = art.dialog({
				title:"详细信息",
				content:'<div>'+request.responseText.substring(request.responseText.indexOf('<body>')+6,request.responseText.indexOf('</body>'))+'</div>',
				lock:true,
				height:320,
				width:400,
				button:[{name:"确定"}]
			});
			return false;
		}
		function closeErrorDialog(){
			dialog.close();
		}
		var dialog = art.dialog({
			title:"信息提示",
			icon:"error",
		    content: content,
		    id: "ajaxErrorDialog",
		    lock:true,
		    button:[{name:"详细信息",callback:showErrorMsg},{name:"确定",callback:closeErrorDialog}]
		});
		dialog.show();
	}
});
function showAjaxLogin(){
	var win = $.ligerDialog.open({
		id:"ajaxLogin",
		height: null, 
		url:getPath()+'/ajaxLoginPage', 
		width: null, 
		showMax: false, 
		showToggle: false, 
		showMin: false,
		showClose:false,
		isResize: false, 
		modal: true, 
		title: "登录",
		buttons:[{text:'登录',onclick:function(item,win){
			if(typeof(win.frame.window.ajaxLogin)=='function'){
				win.frame.window.ajaxLogin(win);
			}
			return false;
		}}]
	});
}